//-
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
    this work for additional information regarding copyright ownership.
    The ASF licenses this file to You under the Apache License, Version 2.0
    (the "License"); you may not use this file except in compliance with
    the License.  You may obtain a copy of the License at

         http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

include /app/helpers/jade/mixins
include /app/configuration/mixins

-var form = 'hadoop'
-var model = '$ctrl.clonedCluster.hadoopConfiguration'
-var plannerModel = model + '.mapReducePlanner'
-var weightedModel = plannerModel + '.Weighted'
-var weightedPlanner = plannerModel + '.kind === "Weighted"'
-var customPlanner = plannerModel + '.kind === "Custom"'
-var libs = model + '.nativeLibraryNames'

panel-collapsible(ng-form=form on-open=`ui.loadPanel('${form}')`)
    panel-title Hadoop configuration
    panel-description Hadoop Accelerator configuration.
    panel-content.pca-form-row(ng-if=`ui.isPanelLoaded('${form}')`)
        .pca-form-column-6.pc-form-grid-row
            .pc-form-grid-col-60
                +form-field__dropdown({
                    label: 'Map reduce planner:',
                    model: `${plannerModel}.kind`,
                    name: '"MapReducePlanner"',
                    placeholder: 'Default',
                    options: '[\
                        {value: "Weighted", label: "Weighted"},\
                        {value: "Custom", label: "Custom"},\
                        {value: null, label: "Default"}\
                    ]',
                    tip: 'Implementation of map reduce planner\
                        <ul>\
                            <li>Weighted - Planner which assigns mappers and reducers based on their "weights"</li>\
                            <li>Custom - Custom planner implementation</li>\
                            <li>Default - Default planner implementation</li>\
                        </ul>'
                })
            .pc-form-group.pc-form-grid-row(ng-show=weightedPlanner)
                .pc-form-grid-col-20
                    +form-field__number({
                        label: 'Local mapper weight:',
                        model: `${weightedModel}.localMapperWeight`,
                        name: '"LocalMapperWeight"',
                        placeholder: '100',
                        min: '0',
                        tip: 'This weight is added to a node when a mapper is assigned and it is input split data is located on this node'
                    })
                .pc-form-grid-col-20
                    +form-field__number({
                        label: 'Remote mapper weight:',
                        model: `${weightedModel}.remoteMapperWeight`,
                        name: '"remoteMapperWeight"',
                        placeholder: '100',
                        min: '0',
                        tip: 'This weight is added to a node when a mapper is assigned, but it is input split data is not located on this node'
                    })
                .pc-form-grid-col-20
                    +form-field__number({
                        label: 'Local reducer weight:',
                        model: `${weightedModel}.localReducerWeight`,
                        name: '"localReducerWeight"',
                        placeholder: '100',
                        min: '0',
                        tip: 'This weight is added to a node when a reducer is assigned and the node have at least one assigned mapper'
                    })
                .pc-form-grid-col-30
                    +form-field__number({
                        label: 'Remote reducer weight:',
                        model: `${weightedModel}.remoteReducerWeight`,
                        name: '"remoteReducerWeight"',
                        placeholder: '100',
                        min: '0',
                        tip: 'This weight is added to a node when a reducer is assigned, but the node does not have any assigned mappers'
                    })
                .pc-form-grid-col-30
                    +form-field__number({
                        label: 'Local mapper weight:',
                        model: `${weightedModel}.preferLocalReducerThresholdWeight`,
                        name: '"preferLocalReducerThresholdWeight"',
                        placeholder: '200',
                        min: '0',
                        tip: 'When threshold is reached, a node with mappers is no longer considered as preferred for further reducer assignments'
                    })
            .pc-form-group.pc-form-grid-row(ng-show=customPlanner)
                .pc-form-grid-col-60
                    +form-field__java-class({
                        label: 'Class name:',
                        model: `${plannerModel}.Custom.className`,
                        name: '"MapReducePlannerCustomClass"',
                        required: customPlanner,
                        tip: 'Custom planner implementation'
                    })
            .pc-form-grid-col-30
                +form-field__number({
                    label: 'Finished job info TTL:',
                    model: `${model}.finishedJobInfoTtl`,
                    name: '"finishedJobInfoTtl"',
                    placeholder: '30000',
                    min: '0',
                    tip: 'Finished job info time-to-live in milliseconds'
                })
            .pc-form-grid-col-30
                +form-field__number({
                    label: 'Max parallel tasks:',
                    model: `${model}.maxParallelTasks`,
                    name: '"maxParallelTasks"',
                    placeholder: 'availableProcessors * 2',
                    min: '1',
                    tip: 'Max number of local tasks that may be executed in parallel'
                })
            .pc-form-grid-col-30
                +form-field__number({
                    label: 'Max task queue size:',
                    model: `${model}.maxTaskQueueSize`,
                    name: '"maxTaskQueueSize"',
                    placeholder: '8192',
                    min: '1',
                    tip: 'Max task queue size'
                })
            .pc-form-grid-col-60
                .ignite-form-field
                    +list-text-field({
                        items: libs,
                        lbl: 'Library name',
                        name: 'libraryName',
                        itemName: 'library name',
                        itemsName: 'library names'
                    })(
                        list-editable-cols=`::[{name: 'Native libraries:'}]`
                    )
                        +form-field__error({ error: 'igniteUnique', message: 'Such native library already exists!' })

        .pca-form-column-6
            +preview-xml-java(model, 'clusterHadoop')
